package com.longe.protobuf;

import com.google.protobuf.InvalidProtocolBufferException;

public class TestProtoBuf {

    public static void main(String[] args) throws InvalidProtocolBufferException {

        StudentPOJO.Student student = StudentPOJO.Student.newBuilder().setId(1).setName("tom").build();

        //序列化为字节数组
        byte[] bytes = student.toByteArray();
        //反序列化为对象
        StudentPOJO.Student finalStudent = StudentPOJO.Student.parseFrom(bytes);
        //输出该对象
        System.err.println(finalStudent);
    }
}
